package cn.tips.dmp.common.upload.service.impl;

import lombok.extern.slf4j.Slf4j;
import cn.tips.dmp.common.upload.po.AttachFile;
import cn.tips.dmp.common.upload.repository.AttachFileRepository;
import cn.tips.dmp.common.upload.service.AttachFileService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: tips_back_end
 * @description:
 * @author: kzl
 * @create: 2020-07-02 19:43
 **/
@Service
@Slf4j
public class AttachFileServiceImpl implements AttachFileService {

    @Resource
    private AttachFileRepository attachFileRepository;

    @Override
    public void delete(Long id) {
        AttachFile attachFile = attachFileRepository.findById(id).orElse(null);
        if(null!=attachFile){
            attachFileRepository.logicDelete(id);
        }
    }

    @Override
    public AttachFile save(AttachFile attachFile) {
        return attachFileRepository.save(attachFile);
    }

    @Override
    public List<AttachFile> getAllByRelationId(Long relationId) {
        return attachFileRepository.getAllByRelationId(relationId);
    }

    @Override
    public AttachFile getOneByRelationId(Long relationId) {
        return attachFileRepository.getAttachFileByRelationId(relationId);
    }

    @Override
    public AttachFile getAttachFileById(Long id) {
        return attachFileRepository.getAttachFileById(id);
    }
}
